{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:03:47.415192Z",
     "start_time": "2019-04-21T02:03:46.969786Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:03:50.326236Z",
     "start_time": "2019-04-21T02:03:50.002845Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 41440 entries, 0 to 41439\n",
      "Data columns (total 51 columns):\n",
      "ID                    41440 non-null int64\n",
      "area                  41440 non-null float64\n",
      "rentType              41440 non-null object\n",
      "houseType             41440 non-null object\n",
      "houseFloor            41440 non-null object\n",
      "totalFloor            41440 non-null int64\n",
      "houseToward           41440 non-null object\n",
      "houseDecoration       41440 non-null object\n",
      "communityName         41440 non-null object\n",
      "city                  41440 non-null object\n",
      "region                41440 non-null object\n",
      "plate                 41440 non-null object\n",
      "buildYear             41440 non-null object\n",
      "saleSecHouseNum       41440 non-null int64\n",
      "subwayStationNum      41440 non-null int64\n",
      "busStationNum         41440 non-null int64\n",
      "interSchoolNum        41440 non-null int64\n",
      "schoolNum             41440 non-null int64\n",
      "privateSchoolNum      41440 non-null int64\n",
      "hospitalNum           41440 non-null int64\n",
      "drugStoreNum          41440 non-null int64\n",
      "gymNum                41440 non-null int64\n",
      "bankNum               41440 non-null int64\n",
      "shopNum               41440 non-null int64\n",
      "parkNum               41440 non-null int64\n",
      "mallNum               41440 non-null int64\n",
      "superMarketNum        41440 non-null int64\n",
      "totalTradeMoney       41440 non-null int64\n",
      "totalTradeArea        41440 non-null float64\n",
      "tradeMeanPrice        41440 non-null float64\n",
      "tradeSecNum           41440 non-null int64\n",
      "totalNewTradeMoney    41440 non-null int64\n",
      "totalNewTradeArea     41440 non-null int64\n",
      "tradeNewMeanPrice     41440 non-null float64\n",
      "tradeNewNum           41440 non-null int64\n",
      "remainNewNum          41440 non-null int64\n",
      "supplyNewNum          41440 non-null int64\n",
      "supplyLandNum         41440 non-null int64\n",
      "supplyLandArea        41440 non-null float64\n",
      "tradeLandNum          41440 non-null int64\n",
      "tradeLandArea         41440 non-null float64\n",
      "landTotalPrice        41440 non-null int64\n",
      "landMeanPrice         41440 non-null float64\n",
      "totalWorkers          41440 non-null int64\n",
      "newWorkers            41440 non-null int64\n",
      "residentPopulation    41440 non-null int64\n",
      "pv                    41422 non-null float64\n",
      "uv                    41422 non-null float64\n",
      "lookNum               41440 non-null int64\n",
      "tradeTime             41440 non-null object\n",
      "tradeMoney            41440 non-null float64\n",
      "dtypes: float64(10), int64(30), object(11)\n",
      "memory usage: 16.1+ MB\n"
     ]
    }
   ],
   "source": [
    "raw_df = pd.read_csv('train_data.csv', sep=',')\n",
    "raw_df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:03:55.074317Z",
     "start_time": "2019-04-21T02:03:55.065846Z"
    }
   },
   "outputs": [],
   "source": [
    "# 数据中有40列数值型，11列非数值型。\n",
    "# categories = []\n",
    "# numerics = []\n",
    "# cols = raw_df.columns\n",
    "# for i, col in enumerate(cols):\n",
    "#     if raw_df[cols[i]].dtype == object:\n",
    "#         categories.append(col)\n",
    "#     else:\n",
    "#         numerics.append(col)\n",
    "# print(categories)\n",
    "# print(len(categories))\n",
    "# print(numerics)\n",
    "# print(len(numerics))\n",
    "\n",
    "categories = ['rentType', 'houseType', 'houseFloor', 'houseToward', 'houseDecoration', 'communityName', 'city', \n",
    "              'region', 'plate', 'buildYear', 'tradeTime']\n",
    "\n",
    "numerics = ['ID', 'area', 'totalFloor', 'saleSecHouseNum', 'subwayStationNum', 'busStationNum', 'interSchoolNum', \n",
    "            'schoolNum', 'privateSchoolNum', 'hospitalNum', 'drugStoreNum', 'gymNum', 'bankNum', 'shopNum', 'parkNum', \n",
    "            'mallNum', 'superMarketNum', 'totalTradeMoney', 'totalTradeArea', 'tradeMeanPrice', 'tradeSecNum', \n",
    "            'totalNewTradeMoney', 'totalNewTradeArea', 'tradeNewMeanPrice', 'tradeNewNum', 'remainNewNum', 'supplyNewNum',\n",
    "            'supplyLandNum', 'supplyLandArea', 'tradeLandNum', 'tradeLandArea', 'landTotalPrice', 'landMeanPrice', 'totalWorkers',\n",
    "            'newWorkers', 'residentPopulation', 'pv', 'uv', 'lookNum', 'tradeMoney']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:03:56.776918Z",
     "start_time": "2019-04-21T02:03:56.604841Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>area</th>\n",
       "      <th>totalFloor</th>\n",
       "      <th>saleSecHouseNum</th>\n",
       "      <th>subwayStationNum</th>\n",
       "      <th>busStationNum</th>\n",
       "      <th>interSchoolNum</th>\n",
       "      <th>schoolNum</th>\n",
       "      <th>privateSchoolNum</th>\n",
       "      <th>hospitalNum</th>\n",
       "      <th>...</th>\n",
       "      <th>tradeLandArea</th>\n",
       "      <th>landTotalPrice</th>\n",
       "      <th>landMeanPrice</th>\n",
       "      <th>totalWorkers</th>\n",
       "      <th>newWorkers</th>\n",
       "      <th>residentPopulation</th>\n",
       "      <th>pv</th>\n",
       "      <th>uv</th>\n",
       "      <th>lookNum</th>\n",
       "      <th>tradeMoney</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>4.144000e+04</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>4.144000e+04</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>41422.000000</td>\n",
       "      <td>41422.000000</td>\n",
       "      <td>41440.000000</td>\n",
       "      <td>4.144000e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1.001221e+08</td>\n",
       "      <td>70.959409</td>\n",
       "      <td>11.413152</td>\n",
       "      <td>1.338538</td>\n",
       "      <td>5.741192</td>\n",
       "      <td>187.197153</td>\n",
       "      <td>1.506395</td>\n",
       "      <td>48.228813</td>\n",
       "      <td>6.271911</td>\n",
       "      <td>4.308736</td>\n",
       "      <td>...</td>\n",
       "      <td>12621.406425</td>\n",
       "      <td>1.045363e+08</td>\n",
       "      <td>724.763918</td>\n",
       "      <td>77250.235497</td>\n",
       "      <td>1137.132095</td>\n",
       "      <td>294514.059459</td>\n",
       "      <td>26945.663512</td>\n",
       "      <td>3089.077085</td>\n",
       "      <td>0.396260</td>\n",
       "      <td>8.837074e+03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>9.376566e+04</td>\n",
       "      <td>88.119569</td>\n",
       "      <td>7.375203</td>\n",
       "      <td>3.180349</td>\n",
       "      <td>4.604929</td>\n",
       "      <td>179.674625</td>\n",
       "      <td>1.687631</td>\n",
       "      <td>29.568448</td>\n",
       "      <td>4.946457</td>\n",
       "      <td>3.359714</td>\n",
       "      <td>...</td>\n",
       "      <td>49853.120341</td>\n",
       "      <td>5.215216e+08</td>\n",
       "      <td>3224.303831</td>\n",
       "      <td>132052.508523</td>\n",
       "      <td>7667.381627</td>\n",
       "      <td>196745.147181</td>\n",
       "      <td>32174.637924</td>\n",
       "      <td>2954.706517</td>\n",
       "      <td>1.653932</td>\n",
       "      <td>5.514287e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000e+08</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>24.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>600.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>49330.000000</td>\n",
       "      <td>17.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>1.000470e+08</td>\n",
       "      <td>42.607500</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>74.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>24.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>13983.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>165293.000000</td>\n",
       "      <td>7928.000000</td>\n",
       "      <td>1053.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.800000e+03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1.000960e+08</td>\n",
       "      <td>65.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>128.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>47.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>38947.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>245872.000000</td>\n",
       "      <td>20196.000000</td>\n",
       "      <td>2375.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>4.000000e+03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>1.001902e+08</td>\n",
       "      <td>90.000000</td>\n",
       "      <td>16.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>258.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>61.000000</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>76668.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>330610.000000</td>\n",
       "      <td>34485.000000</td>\n",
       "      <td>4233.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>5.500000e+03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.003218e+08</td>\n",
       "      <td>15055.000000</td>\n",
       "      <td>88.000000</td>\n",
       "      <td>52.000000</td>\n",
       "      <td>22.000000</td>\n",
       "      <td>824.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>142.000000</td>\n",
       "      <td>24.000000</td>\n",
       "      <td>14.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>555508.010000</td>\n",
       "      <td>6.197570e+09</td>\n",
       "      <td>37513.062490</td>\n",
       "      <td>855400.000000</td>\n",
       "      <td>143700.000000</td>\n",
       "      <td>928198.000000</td>\n",
       "      <td>621864.000000</td>\n",
       "      <td>39876.000000</td>\n",
       "      <td>37.000000</td>\n",
       "      <td>1.000000e+08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 40 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 ID          area    totalFloor  saleSecHouseNum  \\\n",
       "count  4.144000e+04  41440.000000  41440.000000     41440.000000   \n",
       "mean   1.001221e+08     70.959409     11.413152         1.338538   \n",
       "std    9.376566e+04     88.119569      7.375203         3.180349   \n",
       "min    1.000000e+08      1.000000      0.000000         0.000000   \n",
       "25%    1.000470e+08     42.607500      6.000000         0.000000   \n",
       "50%    1.000960e+08     65.000000      7.000000         0.000000   \n",
       "75%    1.001902e+08     90.000000     16.000000         1.000000   \n",
       "max    1.003218e+08  15055.000000     88.000000        52.000000   \n",
       "\n",
       "       subwayStationNum  busStationNum  interSchoolNum     schoolNum  \\\n",
       "count      41440.000000   41440.000000    41440.000000  41440.000000   \n",
       "mean           5.741192     187.197153        1.506395     48.228813   \n",
       "std            4.604929     179.674625        1.687631     29.568448   \n",
       "min            0.000000      24.000000        0.000000      9.000000   \n",
       "25%            2.000000      74.000000        0.000000     24.000000   \n",
       "50%            5.000000     128.000000        1.000000     47.000000   \n",
       "75%            7.000000     258.000000        3.000000     61.000000   \n",
       "max           22.000000     824.000000        8.000000    142.000000   \n",
       "\n",
       "       privateSchoolNum   hospitalNum      ...       tradeLandArea  \\\n",
       "count      41440.000000  41440.000000      ...        41440.000000   \n",
       "mean           6.271911      4.308736      ...        12621.406425   \n",
       "std            4.946457      3.359714      ...        49853.120341   \n",
       "min            0.000000      0.000000      ...            0.000000   \n",
       "25%            2.000000      1.000000      ...            0.000000   \n",
       "50%            5.000000      4.000000      ...            0.000000   \n",
       "75%            9.000000      6.000000      ...            0.000000   \n",
       "max           24.000000     14.000000      ...       555508.010000   \n",
       "\n",
       "       landTotalPrice  landMeanPrice   totalWorkers     newWorkers  \\\n",
       "count    4.144000e+04   41440.000000   41440.000000   41440.000000   \n",
       "mean     1.045363e+08     724.763918   77250.235497    1137.132095   \n",
       "std      5.215216e+08    3224.303831  132052.508523    7667.381627   \n",
       "min      0.000000e+00       0.000000     600.000000       0.000000   \n",
       "25%      0.000000e+00       0.000000   13983.000000       0.000000   \n",
       "50%      0.000000e+00       0.000000   38947.000000       0.000000   \n",
       "75%      0.000000e+00       0.000000   76668.000000       0.000000   \n",
       "max      6.197570e+09   37513.062490  855400.000000  143700.000000   \n",
       "\n",
       "       residentPopulation             pv            uv       lookNum  \\\n",
       "count        41440.000000   41422.000000  41422.000000  41440.000000   \n",
       "mean        294514.059459   26945.663512   3089.077085      0.396260   \n",
       "std         196745.147181   32174.637924   2954.706517      1.653932   \n",
       "min          49330.000000      17.000000      6.000000      0.000000   \n",
       "25%         165293.000000    7928.000000   1053.000000      0.000000   \n",
       "50%         245872.000000   20196.000000   2375.000000      0.000000   \n",
       "75%         330610.000000   34485.000000   4233.000000      0.000000   \n",
       "max         928198.000000  621864.000000  39876.000000     37.000000   \n",
       "\n",
       "         tradeMoney  \n",
       "count  4.144000e+04  \n",
       "mean   8.837074e+03  \n",
       "std    5.514287e+05  \n",
       "min    0.000000e+00  \n",
       "25%    2.800000e+03  \n",
       "50%    4.000000e+03  \n",
       "75%    5.500000e+03  \n",
       "max    1.000000e+08  \n",
       "\n",
       "[8 rows x 40 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "raw_df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:04:04.358279Z",
     "start_time": "2019-04-21T02:04:04.332030Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>area</th>\n",
       "      <th>rentType</th>\n",
       "      <th>houseType</th>\n",
       "      <th>houseFloor</th>\n",
       "      <th>totalFloor</th>\n",
       "      <th>houseToward</th>\n",
       "      <th>houseDecoration</th>\n",
       "      <th>communityName</th>\n",
       "      <th>city</th>\n",
       "      <th>...</th>\n",
       "      <th>landTotalPrice</th>\n",
       "      <th>landMeanPrice</th>\n",
       "      <th>totalWorkers</th>\n",
       "      <th>newWorkers</th>\n",
       "      <th>residentPopulation</th>\n",
       "      <th>pv</th>\n",
       "      <th>uv</th>\n",
       "      <th>lookNum</th>\n",
       "      <th>tradeTime</th>\n",
       "      <th>tradeMoney</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100309852</td>\n",
       "      <td>68.06</td>\n",
       "      <td>未知方式</td>\n",
       "      <td>2室1厅1卫</td>\n",
       "      <td>低</td>\n",
       "      <td>16</td>\n",
       "      <td>暂无数据</td>\n",
       "      <td>其他</td>\n",
       "      <td>XQ00051</td>\n",
       "      <td>SH</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>28248</td>\n",
       "      <td>614</td>\n",
       "      <td>111546</td>\n",
       "      <td>1124.0</td>\n",
       "      <td>284.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2018/11/28</td>\n",
       "      <td>2000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100307942</td>\n",
       "      <td>125.55</td>\n",
       "      <td>未知方式</td>\n",
       "      <td>3室2厅2卫</td>\n",
       "      <td>中</td>\n",
       "      <td>14</td>\n",
       "      <td>暂无数据</td>\n",
       "      <td>简装</td>\n",
       "      <td>XQ00130</td>\n",
       "      <td>SH</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>14823</td>\n",
       "      <td>148</td>\n",
       "      <td>157552</td>\n",
       "      <td>701.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>2018/12/16</td>\n",
       "      <td>2000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100307764</td>\n",
       "      <td>132.00</td>\n",
       "      <td>未知方式</td>\n",
       "      <td>3室2厅2卫</td>\n",
       "      <td>低</td>\n",
       "      <td>32</td>\n",
       "      <td>暂无数据</td>\n",
       "      <td>其他</td>\n",
       "      <td>XQ00179</td>\n",
       "      <td>SH</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>77645</td>\n",
       "      <td>520</td>\n",
       "      <td>131744</td>\n",
       "      <td>57.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>1</td>\n",
       "      <td>2018/12/22</td>\n",
       "      <td>16000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100306518</td>\n",
       "      <td>57.00</td>\n",
       "      <td>未知方式</td>\n",
       "      <td>1室1厅1卫</td>\n",
       "      <td>中</td>\n",
       "      <td>17</td>\n",
       "      <td>暂无数据</td>\n",
       "      <td>精装</td>\n",
       "      <td>XQ00313</td>\n",
       "      <td>SH</td>\n",
       "      <td>...</td>\n",
       "      <td>332760000</td>\n",
       "      <td>3080.0331</td>\n",
       "      <td>8750</td>\n",
       "      <td>1665</td>\n",
       "      <td>253337</td>\n",
       "      <td>888.0</td>\n",
       "      <td>279.0</td>\n",
       "      <td>9</td>\n",
       "      <td>2018/12/21</td>\n",
       "      <td>1600.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>100305262</td>\n",
       "      <td>129.00</td>\n",
       "      <td>未知方式</td>\n",
       "      <td>3室2厅3卫</td>\n",
       "      <td>低</td>\n",
       "      <td>2</td>\n",
       "      <td>暂无数据</td>\n",
       "      <td>毛坯</td>\n",
       "      <td>XQ01257</td>\n",
       "      <td>SH</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>800</td>\n",
       "      <td>117</td>\n",
       "      <td>125309</td>\n",
       "      <td>2038.0</td>\n",
       "      <td>480.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2018/11/18</td>\n",
       "      <td>2900.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 51 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          ID    area rentType houseType houseFloor  totalFloor houseToward  \\\n",
       "0  100309852   68.06     未知方式    2室1厅1卫          低          16        暂无数据   \n",
       "1  100307942  125.55     未知方式    3室2厅2卫          中          14        暂无数据   \n",
       "2  100307764  132.00     未知方式    3室2厅2卫          低          32        暂无数据   \n",
       "3  100306518   57.00     未知方式    1室1厅1卫          中          17        暂无数据   \n",
       "4  100305262  129.00     未知方式    3室2厅3卫          低           2        暂无数据   \n",
       "\n",
       "  houseDecoration communityName city     ...     landTotalPrice landMeanPrice  \\\n",
       "0              其他       XQ00051   SH     ...                  0        0.0000   \n",
       "1              简装       XQ00130   SH     ...                  0        0.0000   \n",
       "2              其他       XQ00179   SH     ...                  0        0.0000   \n",
       "3              精装       XQ00313   SH     ...          332760000     3080.0331   \n",
       "4              毛坯       XQ01257   SH     ...                  0        0.0000   \n",
       "\n",
       "  totalWorkers  newWorkers  residentPopulation      pv     uv  lookNum  \\\n",
       "0        28248         614              111546  1124.0  284.0        0   \n",
       "1        14823         148              157552   701.0   22.0        1   \n",
       "2        77645         520              131744    57.0   20.0        1   \n",
       "3         8750        1665              253337   888.0  279.0        9   \n",
       "4          800         117              125309  2038.0  480.0        0   \n",
       "\n",
       "    tradeTime  tradeMoney  \n",
       "0  2018/11/28      2000.0  \n",
       "1  2018/12/16      2000.0  \n",
       "2  2018/12/22     16000.0  \n",
       "3  2018/12/21      1600.0  \n",
       "4  2018/11/18      2900.0  \n",
       "\n",
       "[5 rows x 51 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "raw_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:04:14.223491Z",
     "start_time": "2019-04-21T02:04:14.198692Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rentType ['未知方式' '整租' '合租' '--']\n",
      "\n",
      "houseType ['2室1厅1卫' '3室2厅2卫' '1室1厅1卫' '3室2厅3卫' '4室3厅3卫' '2室2厅1卫' '3室2厅1卫' '3室1厅1卫'\n",
      " '5室2厅3卫' '2室1厅2卫' '4室2厅2卫' '1室0厅1卫' '4室2厅3卫' '1室0厅0卫' '2室2厅2卫' '2室0厅1卫'\n",
      " '1室2厅1卫' '6室3厅4卫' '4室2厅4卫' '4室2厅1卫' '5室3厅5卫' '4室3厅2卫' '6室3厅2卫' '5室2厅2卫'\n",
      " '5室2厅4卫' '1室1厅2卫' '4室1厅3卫' '3室0厅1卫' '5室3厅4卫' '5室5厅4卫' '4室3厅5卫' '4室3厅4卫'\n",
      " '0室0厅1卫' '5室2厅5卫' '7室2厅3卫' '3室2厅4卫' '3室3厅2卫' '3室1厅2卫' '5室4厅5卫' '5室3厅3卫'\n",
      " '5室2厅6卫' '5室3厅1卫' '3室4厅4卫' '6室2厅4卫' '6室1厅4卫' '3室1厅3卫' '6室2厅3卫' '5室4厅3卫'\n",
      " '2室2厅3卫' '4室1厅1卫' '5室1厅1卫' '1室2厅2卫' '6室1厅1卫' '4室1厅2卫' '5室3厅6卫' '4室2厅5卫'\n",
      " '6室2厅2卫' '5室1厅2卫' '5室4厅4卫' '2室3厅1卫' '6室4厅2卫' '7室1厅7卫' '3室3厅4卫' '3室2厅5卫'\n",
      " '6室3厅5卫' '4室0厅1卫' '5室4厅2卫' '7室4厅3卫' '6室3厅3卫' '6室2厅5卫' '6室2厅7卫' '4室0厅4卫'\n",
      " '2室2厅0卫' '3室3厅3卫' '8室3厅4卫' '6室2厅6卫' '1室1厅0卫' '2室1厅0卫' '5室3厅2卫' '5室2厅1卫'\n",
      " '2室0厅0卫' '7室1厅1卫' '6室2厅1卫' '8室2厅4卫' '7室2厅1卫' '2室0厅2卫' '3室0厅2卫' '4室0厅2卫'\n",
      " '3室1厅0卫' '3室0厅0卫' '9室2厅5卫' '6室4厅5卫' '4室4厅2卫' '4室1厅4卫' '8室4厅4卫' '7室2厅4卫'\n",
      " '7室1厅3卫' '8室2厅3卫' '7室3厅4卫' '5室1厅5卫' '2室1厅3卫' '6室4厅4卫' '5室1厅3卫' '9室3厅8卫']\n",
      "\n",
      "houseFloor ['低' '中' '高']\n",
      "\n",
      "houseToward ['暂无数据' '西南' '西北' '西' '南北' '南' '东西' '东南' '东' '北']\n",
      "\n",
      "houseDecoration ['其他' '简装' '精装' '毛坯']\n",
      "\n",
      "communityName ['XQ00051' 'XQ00130' 'XQ00179' ... 'XQ00607' 'XQ00957' 'XQ00579']\n",
      "\n",
      "city ['SH']\n",
      "\n",
      "region ['RG00001' 'RG00002' 'RG00003' 'RG00006' 'RG00007' 'RG00010' 'RG00008'\n",
      " 'RG00004' 'RG00012' 'RG00009' 'RG00011' 'RG00013' 'RG00014' 'RG00005'\n",
      " 'RG00015']\n",
      "\n",
      "plate ['BK00064' 'BK00049' 'BK00050' 'BK00051' 'BK00044' 'BK00052' 'BK00031'\n",
      " 'BK00028' 'BK00017' 'BK00045' 'BK00027' 'BK00041' 'BK00047' 'BK00009'\n",
      " 'BK00025' 'BK00024' 'BK00014' 'BK00026' 'BK00042' 'BK00046' 'BK00043'\n",
      " 'BK00013' 'BK00012' 'BK00005' 'BK00011' 'BK00010' 'BK00003' 'BK00033'\n",
      " 'BK00053' 'BK00006' 'BK00004' 'BK00002' 'BK00007' 'BK00015' 'BK00016'\n",
      " 'BK00019' 'BK00030' 'BK00048' 'BK00018' 'BK00008' 'BK00029' 'BK00065'\n",
      " 'BK00035' 'BK00036' 'BK00022' 'BK00023' 'BK00054' 'BK00038' 'BK00037'\n",
      " 'BK00034' 'BK00058' 'BK00066' 'BK00039' 'BK00057' 'BK00020' 'BK00059'\n",
      " 'BK00060' 'BK00063' 'BK00055' 'BK00061' 'BK00040' 'BK00056' 'BK00062'\n",
      " 'BK00021' 'BK00032' 'BK00001']\n",
      "\n",
      "buildYear ['1953' '2007' '暂无信息' '2003' '2014' '1997' '1993' '1994' '1998' '2000'\n",
      " '1995' '1999' '2015' '1981' '2002' '2010' '2011' '1989' '1983' '2001'\n",
      " '2012' '1996' '2004' '2006' '2009' '2008' '1984' '2017' '1976' '1986'\n",
      " '1988' '1992' '2005' '1987' '2016' '1965' '1990' '1985' '1978' '2013'\n",
      " '1980' '1954' '1982' '1968' '1940' '1966' '1970' '1937' '1979' '1974'\n",
      " '1964' '1991' '1977' '1956' '1930' '1952' '1957' '1936' '1967' '1972'\n",
      " '1975' '1955' '1949' '1912' '1958' '1973' '1932' '1963' '1931' '1926'\n",
      " '1939' '1951' '1960' '1910' '1969' '1920' '1959' '1962' '1961' '1950']\n",
      "\n",
      "tradeTime ['2018/11/28' '2018/12/16' '2018/12/22' '2018/12/21' '2018/11/18'\n",
      " '2018/11/14' '2018/3/24' '2018/3/19' '2018/4/26' '2018/4/29' '2018/3/30'\n",
      " '2018/4/1' '2018/4/10' '2018/5/15' '2018/2/10' '2018/3/25' '2018/6/1'\n",
      " '2018/4/16' '2018/3/18' '2018/3/28' '2018/2/28' '2018/11/6' '2018/3/16'\n",
      " '2018/3/15' '2018/4/8' '2018/5/20' '2018/3/26' '2018/3/27' '2018/4/17'\n",
      " '2018/4/24' '2018/5/31' '2018/2/4' '2018/2/25' '2018/2/7' '2018/2/11'\n",
      " '2018/4/3' '2018/2/9' '2018/3/10' '2018/4/15' '2018/5/30' '2018/7/30'\n",
      " '2018/3/4' '2018/3/11' '2018/3/23' '2018/2/26' '2018/8/5' '2018/3/14'\n",
      " '2018/3/17' '2018/5/22' '2018/3/7' '2018/3/9' '2018/11/3' '2018/3/22'\n",
      " '2018/2/1' '2018/5/10' '2018/7/29' '2018/2/6' '2018/3/13' '2018/4/13'\n",
      " '2018/5/13' '2018/5/5' '2018/2/3' '2018/4/14' '2018/5/26' '2018/7/28'\n",
      " '2018/5/27' '2018/7/7' '2018/2/24' '2018/4/7' '2018/5/9' '2018/4/12'\n",
      " '2018/5/18' '2018/5/25' '2018/7/14' '2018/3/31' '2018/6/26' '2018/3/5'\n",
      " '2018/3/8' '2018/3/21' '2018/7/24' '2018/6/8' '2018/5/7' '2018/5/19'\n",
      " '2018/4/21' '2018/3/1' '2018/3/12' '2018/5/16' '2018/4/19' '2018/1/22'\n",
      " '2018/2/23' '2018/2/27' '2018/4/22' '2018/3/2' '2018/6/6' '2018/2/2'\n",
      " '2018/5/2' '2018/4/9' '2018/2/5' '2018/4/2' '2018/6/4' '2018/4/27'\n",
      " '2018/3/20' '2018/3/29' '2018/7/1' '2018/3/6' '2018/5/8' '2018/6/28'\n",
      " '2018/8/8' '2018/2/8' '2018/5/12' '2018/6/11' '2018/1/26' '2018/7/23'\n",
      " '2018/8/9' '2018/6/24' '2018/7/17' '2018/8/12' '2018/4/20' '2018/5/11'\n",
      " '2018/6/10' '2018/9/3' '2018/5/6' '2018/8/2' '2018/6/7' '2018/3/3'\n",
      " '2018/5/14' '2018/7/21' '2018/6/22' '2018/4/6' '2018/7/12' '2018/6/25'\n",
      " '2018/6/9' '2018/10/10' '2018/6/5' '2018/9/26' '2018/10/13' '2018/4/23'\n",
      " '2018/10/28' '2018/7/22' '2018/8/26' '2018/9/2' '2018/6/23' '2018/6/13'\n",
      " '2018/7/25' '2018/7/16' '2018/9/18' '2018/5/29' '2018/6/14' '2018/8/28'\n",
      " '2018/5/21' '2018/10/29' '2018/8/30' '2018/8/20' '2018/5/23' '2018/8/16'\n",
      " '2018/6/2' '2018/6/17' '2018/6/30' '2018/8/17' '2018/7/11' '2018/6/27'\n",
      " '2018/10/30' '2018/6/16' '2018/4/30' '2018/1/31' '2018/8/19' '2018/9/15'\n",
      " '2018/2/12' '2018/5/17' '2018/6/20' '2018/8/21' '2018/4/4' '2018/4/18'\n",
      " '2018/4/11' '2018/4/25' '2018/8/10' '2018/9/30' '2018/4/28' '2018/5/4'\n",
      " '2018/9/13' '2018/6/21' '2018/9/29' '2018/8/14' '2018/7/5' '2018/6/19'\n",
      " '2018/8/31' '2018/9/10' '2018/1/28' '2018/5/24' '2018/7/6' '2018/9/16'\n",
      " '2018/2/13' '2018/8/4' '2018/5/3' '2018/6/15' '2018/10/15' '2018/6/3'\n",
      " '2018/7/8' '2018/5/28' '2018/8/27' '2018/7/13' '2018/10/22' '2018/10/25'\n",
      " '2018/8/11' '2018/12/28' '2018/12/4' '2018/12/10' '2018/11/29'\n",
      " '2018/11/22' '2018/12/5' '2018/12/12' '2018/12/13' '2018/11/13'\n",
      " '2018/11/12' '2018/11/10' '2018/10/31' '2018/8/13' '2018/6/12'\n",
      " '2018/1/13' '2018/9/7' '2018/5/1' '2018/6/29' '2018/4/5' '2018/1/11'\n",
      " '2018/7/15' '2018/9/4' '2018/8/23' '2018/10/1' '2018/9/27' '2018/9/12'\n",
      " '2018/9/8' '2018/8/29' '2018/9/21' '2018/9/22' '2018/10/12' '2018/7/31'\n",
      " '2018/9/25' '2018/9/19' '2018/9/23' '2018/8/1' '2018/8/22' '2018/10/17'\n",
      " '2018/9/24' '2018/9/5' '2018/10/7' '2018/7/19' '2018/10/9' '2018/10/24'\n",
      " '2018/8/25' '2018/10/21' '2018/10/26' '2018/10/18' '2018/7/9'\n",
      " '2018/12/30' '2018/12/23' '2018/11/11' '2018/11/16' '2018/11/5'\n",
      " '2018/1/1' '2018/8/24' '2018/7/18' '2018/9/6' '2018/10/11' '2018/12/2'\n",
      " '2018/12/3' '2018/11/27' '2018/11/26' '2018/12/14' '2018/12/20'\n",
      " '2018/12/26' '2018/11/23' '2018/11/20' '2018/1/9' '2018/1/5' '2018/1/24'\n",
      " '2018/8/3' '2018/1/25' '2018/1/6' '2018/1/27' '2018/7/3' '2018/2/22'\n",
      " '2018/1/14' '2018/1/8' '2018/1/12' '2018/1/3' '2018/1/4' '2018/2/21'\n",
      " '2018/9/1' '2018/9/14' '2018/8/15' '2018/8/6' '2018/8/7' '2018/1/23'\n",
      " '2018/9/9' '2018/1/29' '2018/9/20' '2018/9/28' '2018/10/14' '2018/9/11'\n",
      " '2018/10/27' '2018/1/15' '2018/7/2' '2018/1/30' '2018/10/20' '2018/1/10'\n",
      " '2018/12/31' '2018/12/29' '2018/12/9' '2018/11/30' '2018/12/1'\n",
      " '2018/12/19' '2018/12/15' '2018/12/27' '2018/12/18' '2018/11/24'\n",
      " '2018/12/25' '2018/12/11' '2018/12/17' '2018/12/7' '2018/11/25'\n",
      " '2018/12/24' '2018/11/9' '2018/12/8' '2018/12/6' '2018/11/17' '2018/11/8'\n",
      " '2018/11/21' '2018/11/19' '2018/11/15' '2018/11/1' '2018/11/7'\n",
      " '2018/11/2' '2018/11/4' '2018/6/18' '2018/7/4' '2018/8/18' '2018/7/20'\n",
      " '2018/7/10' '2018/7/27' '2018/7/26' '2018/10/6' '2018/10/16' '2018/10/8'\n",
      " '2018/9/17' '2018/10/2' '2018/10/3' '2018/10/5' '2018/10/23' '2018/10/19'\n",
      " '2018/1/7' '2018/1/20' '2018/10/4' '2018/1/21' '2018/1/18' '2018/1/19'\n",
      " '2018/1/16' '2018/1/17' '2018/1/2' '2018/2/20' '2018/2/17' '2018/2/19']\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 看一下类别型特征的包含类别\n",
    "for _, col in enumerate(categories):\n",
    "    print(col, raw_df[col].unique())\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:04:25.613926Z",
     "start_time": "2019-04-21T02:04:25.582182Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['rentType', 'houseType', 'houseFloor', 'houseToward', 'houseDecoration',\n",
       "       'communityName', 'city', 'region', 'plate', 'buildYear', 'tradeTime',\n",
       "       'area', 'totalFloor', 'saleSecHouseNum', 'subwayStationNum',\n",
       "       'busStationNum', 'interSchoolNum', 'schoolNum', 'privateSchoolNum',\n",
       "       'hospitalNum', 'drugStoreNum', 'gymNum', 'bankNum', 'shopNum',\n",
       "       'parkNum', 'mallNum', 'superMarketNum', 'totalTradeMoney',\n",
       "       'totalTradeArea', 'tradeMeanPrice', 'tradeSecNum', 'totalNewTradeMoney',\n",
       "       'totalNewTradeArea', 'tradeNewMeanPrice', 'tradeNewNum', 'remainNewNum',\n",
       "       'supplyNewNum', 'supplyLandArea', 'tradeLandArea', 'landTotalPrice',\n",
       "       'landMeanPrice', 'totalWorkers', 'newWorkers', 'residentPopulation',\n",
       "       'pv', 'uv', 'lookNum', 'tradeMoney'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 类别型剔除：communityName，city，region，plate，tradeTime\n",
    "cates_feat =['rentType', 'houseType', 'houseFloor', 'houseToward', 'houseDecoration', 'buildYear']\n",
    "\n",
    "# 数值型剔除：'ID'，'supplyLandNum', 'tradeLandNum',\n",
    "num_feat = ['area', 'totalFloor', 'saleSecHouseNum', 'subwayStationNum', 'busStationNum', 'interSchoolNum', \n",
    "            'schoolNum', 'privateSchoolNum', 'hospitalNum', 'drugStoreNum', 'gymNum', 'bankNum', 'shopNum', 'parkNum', \n",
    "            'mallNum', 'superMarketNum', 'totalTradeMoney', 'totalTradeArea', 'tradeMeanPrice', 'tradeSecNum', \n",
    "            'totalNewTradeMoney', 'totalNewTradeArea', 'tradeNewMeanPrice', 'tradeNewNum', 'remainNewNum', 'supplyNewNum',\n",
    "             'supplyLandArea', 'tradeLandArea', 'landTotalPrice', 'landMeanPrice', 'totalWorkers',\n",
    "            'newWorkers', 'residentPopulation', 'pv', 'uv', 'lookNum', 'tradeMoney']\n",
    "label = ['tradeMoney']\n",
    "raw_df = raw_df[categories + num_feat]\n",
    "raw_df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:04:35.861600Z",
     "start_time": "2019-04-21T02:04:35.740315Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 41440 entries, 0 to 41439\n",
      "Data columns (total 37 columns):\n",
      "rentType                41440 non-null object\n",
      "houseType               41440 non-null object\n",
      "houseFloor              41440 non-null object\n",
      "houseToward             41440 non-null object\n",
      "houseDecoration         41440 non-null object\n",
      "communityName           41440 non-null object\n",
      "city                    41440 non-null object\n",
      "region                  41440 non-null object\n",
      "plate                   41440 non-null object\n",
      "buildYear               41440 non-null object\n",
      "tradeTime               41440 non-null object\n",
      "area                    41440 non-null float64\n",
      "totalFloor              41440 non-null int64\n",
      "saleSecHouseNum         41440 non-null int64\n",
      "totalTradeMoney         41440 non-null int64\n",
      "totalTradeArea          41440 non-null float64\n",
      "tradeMeanPrice          41440 non-null float64\n",
      "tradeSecNum             41440 non-null int64\n",
      "totalNewTradeMoney      41440 non-null int64\n",
      "totalNewTradeArea       41440 non-null int64\n",
      "tradeNewMeanPrice       41440 non-null float64\n",
      "tradeNewNum             41440 non-null int64\n",
      "remainNewNum            41440 non-null int64\n",
      "supplyNewNum            41440 non-null int64\n",
      "landTotalPrice          41440 non-null int64\n",
      "landMeanPrice           41440 non-null float64\n",
      "totalWorkers            41440 non-null int64\n",
      "newWorkers              41440 non-null int64\n",
      "residentPopulation      41440 non-null int64\n",
      "pv                      41422 non-null float64\n",
      "uv                      41422 non-null float64\n",
      "lookNum                 41440 non-null int64\n",
      "tradeMoney              41440 non-null float64\n",
      "stationNum              41440 non-null int64\n",
      "medicalNum              41440 non-null int64\n",
      "lifeHouseNum            41440 non-null int64\n",
      "landSupplyTradeRatio    6272 non-null float64\n",
      "dtypes: float64(9), int64(17), object(11)\n",
      "memory usage: 11.7+ MB\n"
     ]
    }
   ],
   "source": [
    "# 配套设施 合并： \n",
    "# stationNum ==>   'subwayStationNum', 'busStationNum'\n",
    "# schoolNum  ==>   'interSchoolNum','schoolNum', 'privateSchoolNum' ==》\n",
    "# medicalNum ==>   'hospitalNum', 'drugStoreNum'\n",
    "# lifeHouseNum ==> 'gymNum', 'bankNum', 'shopNum', 'parkNum', 'mallNum', 'superMarketNum'\n",
    "# 土地供需比 = 土地供应建筑面积/土地成交建筑面积，土地供需比越小，市场越供不应求。\n",
    "# landSupplyTradeRatio ==> supplyLandArea / tradeLandArea\n",
    "raw_df['stationNum'] = raw_df['subwayStationNum'] + raw_df['busStationNum']\n",
    "raw_df['schoolNum'] = raw_df['interSchoolNum'] + raw_df['schoolNum'] + raw_df['privateSchoolNum']\n",
    "raw_df['medicalNum'] = raw_df['hospitalNum'] + raw_df['drugStoreNum']\n",
    "raw_df['lifeHouseNum'] = raw_df['gymNum'] + raw_df['bankNum'] + raw_df['shopNum'] + raw_df['parkNum'] + raw_df['mallNum'] + raw_df['superMarketNum']\n",
    "raw_df['landSupplyTradeRatio'] = raw_df['supplyLandArea'] / raw_df['tradeLandArea']\n",
    "\n",
    "now_df = raw_df.drop(['subwayStationNum','busStationNum',\n",
    "                      'interSchoolNum', 'schoolNum', 'privateSchoolNum',\n",
    "                      'hospitalNum', 'drugStoreNum',\n",
    "                      'gymNum', 'bankNum', 'shopNum', 'parkNum', 'mallNum', 'superMarketNum',\n",
    "                      'supplyLandArea','tradeLandArea'], axis=1)\n",
    "now_df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:27:33.682453Z",
     "start_time": "2019-04-21T02:27:32.526277Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "now_df.to_csv('now_df.csv', sep=',', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-04-21T02:22:57.548246Z",
     "start_time": "2019-04-21T02:22:57.530449Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\work\\software\\Anaconda5.3.0\\lib\\site-packages\\ipykernel_launcher.py:3: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n",
      "  This is separate from the ipykernel package so we can avoid doing imports until\n"
     ]
    },
    {
     "ename": "IndexingError",
     "evalue": "Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexingError\u001b[0m                             Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-20-2438ee9597eb>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m# 删除landSupplyTradeRatio列中为NaN的行\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;31m# 先定位到所在行的index，然后对该index进行drop操作即可\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mnow_df\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdrop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnow_df\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0misnan\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnow_df\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'landSupplyTradeRatio'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minplace\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      4\u001b[0m \u001b[0mnow_df\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minfo\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\work\\software\\Anaconda5.3.0\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   1956\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mSeries\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mIndex\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1957\u001b[0m             \u001b[1;31m# either boolean or fancy integer index\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1958\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_array\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1959\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mDataFrame\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1960\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_frame\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\work\\software\\Anaconda5.3.0\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m_getitem_array\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   1996\u001b[0m             \u001b[1;31m# check_bool_indexer will throw exception if Series key cannot\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1997\u001b[0m             \u001b[1;31m# be reindexed to match DataFrame rows\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1998\u001b[1;33m             \u001b[0mkey\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcheck_bool_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1999\u001b[0m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnonzero\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2000\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtake\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconvert\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\work\\software\\Anaconda5.3.0\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36mcheck_bool_indexer\u001b[1;34m(ax, key)\u001b[0m\n\u001b[0;32m   1937\u001b[0m         \u001b[0mmask\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0misnull\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_values\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1938\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mmask\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0many\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1939\u001b[1;33m             raise IndexingError('Unalignable boolean Series provided as '\n\u001b[0m\u001b[0;32m   1940\u001b[0m                                 \u001b[1;34m'indexer (index of the boolean Series and of '\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1941\u001b[0m                                 'the indexed object do not match')\n",
      "\u001b[1;31mIndexingError\u001b[0m: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match"
     ]
    }
   ],
   "source": [
    "# 删除landSupplyTradeRatio列中为NaN的行\n",
    "# 先定位到所在行的index，然后对该index进行drop操作即可\n",
    "now_df.drop(now_df[np.isnan(now_df['landSupplyTradeRatio'])].index, inplace=True)\n",
    "now_df.info()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
